package decorate.thread;


/**
 * Thread
 * Runnable
 * 线程的设计：采用了装饰器模式
 * Thread线程实现了Runnable，实现了Runnable的run()方法，
 * Thread中有一个变量target,类型是Runnable。
 * 运行run方法时，若target不为空，则运行target的run,
 */
public class Test {

    public static void main(String[] args) {
        Thread thread = new Thread("thread"){
            @Override
            public void run() {
                System.out.println(getName());
            }
        };
        thread.start();

        Runnable runnable = new Runnable() {
            @Override
            public void run() {
                System.out.println("runnable");
            }
        };

        Thread thread1 = new Thread(runnable,"thread1"){
            @Override
            public void run() {
                super.run();
                System.out.println("111");
            }
        };
        thread1.start();
    }
}
